<?php
class Categories_Model extends General_Model {
	function getCategoriesList() {
//		$query = $this->db->get ( 'categories' );
		$query=$this->db->query("SELECT ci_categories.*,ci_gallery.file_name FROM `ci_categories`
							LEFT JOIN ci_gallery ON ci_gallery.id=ci_categories.img_id");
		$categories = $query->result_array();
		return $categories;
	}
	function getCatDetail($catid) {
//		$this->db->where ( 'id', $catid );
//		$query = $this->db->get ( 'categories' );
		$query=$this->db->query("SELECT ci_categories.*,ci_gallery.file_name FROM `ci_categories`
							LEFT JOIN ci_gallery ON ci_gallery.id=ci_categories.img_id WHERE ci_categories.id ='$catid'");
		$cat = $query->row ();
		return $cat;
	}
	function getPostList($catid) {
		$this->db->where ( 'catid', $catid );
		$query = $this->db->get ( 'posts' );
		$products = $query->result ();
		return $products;
	}

	function getPostDetail($id) {
		$this->db->where ( 'id', $id );
		$query = $this->db->get ( 'posts' );
		$prod = $query->row ();
		return $prod;
	}
	function del_cat($id) {
		$this->db->where ( 'id', $id );
		$this->db->limit ( 1, 0 );
		$this->db->delete ( 'categories' );

		$this->db->where ( 'catid', $id );
		$this->db->delete ( 'products' );

		return TRUE;
	}
	
	function getRecruitments(){
		$this->db->where ( 'catid', '99999' );
		$query = $this->db->get ( 'posts' );
		$products = $query->result ();
		return $products;
	}
}